package UserInterface;

import java.awt.Color;
import java.util.Random;

import javax.swing.DefaultListModel;
import javax.swing.JColorChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

import shapes.Shape;

import elements.DisplayFile;
import elements.Viewport;

public class MainFrame extends javax.swing.JFrame {

	DefaultListModel shapeList;
	DefaultListModel polPtsList;
	private Color color;
	private String name;

	public DisplayFile displayFile = new DisplayFile();

	public MainFrame() {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			e.printStackTrace();
		}

		shapeList = new DefaultListModel();
		polPtsList = new DefaultListModel();
		initComponents();

		color = Color.BLACK;
		btColorShape.setBackground(color);

		displayFile.window.move(0, 0);
		
	}

	public static void main(String args[]) {
		try {
			for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
					.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					javax.swing.UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (javax.swing.UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		}

		java.awt.EventQueue.invokeLater(new Runnable() {

			public void run() {
				new MainFrame().setVisible(true);
			}
		});
	}

	private void initComponents() {

		scrollShapes = new javax.swing.JScrollPane();
		scrollPolPts = new javax.swing.JScrollPane();
		jTabbedPane1 = new javax.swing.JTabbedPane();
		jPanel1 = new javax.swing.JPanel();
		jPanel7 = new javax.swing.JPanel();
		btMoveUp = new javax.swing.JButton();
		btMoveDown = new javax.swing.JButton();
		btMoveRight = new javax.swing.JButton();
		btMoveLeft = new javax.swing.JButton();
		jLabel15 = new javax.swing.JLabel();
		tfMoveStep = new javax.swing.JTextField();
		jPanel10 = new javax.swing.JPanel();
		btRotateLeft = new javax.swing.JButton();
		btRotateRight = new javax.swing.JButton();
		jLabel18 = new javax.swing.JLabel();
		tfRotateDeg = new javax.swing.JTextField();
		jPanel11 = new javax.swing.JPanel();
		btZoomOut = new javax.swing.JButton();
		btZoomIn = new javax.swing.JButton();
		jLabel19 = new javax.swing.JLabel();
		tfZoomStep = new javax.swing.JTextField();
		jPanel2 = new javax.swing.JPanel();
		lsShapes = new javax.swing.JList(shapeList);
		label1 = new java.awt.Label();
		btEditShape = new javax.swing.JButton();
		btRemoveShape = new javax.swing.JButton();
		jSeparator1 = new javax.swing.JSeparator();
		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		txShapeName = new javax.swing.JTextField();
		jLabel3 = new javax.swing.JLabel();
		btColorShape = new javax.swing.JPanel();
		btRandomColor = new javax.swing.JButton();
		jTabbedPane2 = new javax.swing.JTabbedPane();
		jPanel4 = new javax.swing.JPanel();
		jLabel4 = new javax.swing.JLabel();
		tfPtX = new javax.swing.JTextField();
		jLabel5 = new javax.swing.JLabel();
		tfPtY = new javax.swing.JTextField();
		jLabel6 = new javax.swing.JLabel();
		btPtCreate = new javax.swing.JButton();
		jPanel5 = new javax.swing.JPanel();
		btLnCreate = new javax.swing.JButton();
		jLabel7 = new javax.swing.JLabel();
		jLabel8 = new javax.swing.JLabel();
		tfLnX0 = new javax.swing.JTextField();
		jLabel9 = new javax.swing.JLabel();
		tfLnY0 = new javax.swing.JTextField();
		jLabel10 = new javax.swing.JLabel();
		tfLnX1 = new javax.swing.JTextField();
		tfLnY1 = new javax.swing.JTextField();
		jLabel11 = new javax.swing.JLabel();
		jPanel6 = new javax.swing.JPanel();
		btPlCreate = new javax.swing.JButton();
		jLabel12 = new javax.swing.JLabel();
		jLabel13 = new javax.swing.JLabel();
		tfPlX = new javax.swing.JTextField();
		jLabel14 = new javax.swing.JLabel();
		tfPlY = new javax.swing.JTextField();
		btPlAddPt = new javax.swing.JButton();
		lsPlPoints = new javax.swing.JList(polPtsList);
		btPlRemovePoint = new javax.swing.JButton();
		cbPlSolid = new javax.swing.JCheckBox();
		jPanel3 = new javax.swing.JPanel();
		viewport = new Viewport(displayFile.window);
		jMenuBar1 = new javax.swing.JMenuBar();
		jMenu1 = new javax.swing.JMenu();
		menuSobre = new javax.swing.JMenu();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		jPanel7.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Navegação"));

		btMoveUp.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/assets/u.png"))); // NOI18N
		btMoveUp.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btMoveUpActionPerformed(evt);
			}
		});

		btMoveDown.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/assets/d.png"))); // NOI18N
		btMoveDown.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btMoveDownActionPerformed(evt);
			}
		});

		btMoveRight.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/assets/r.png"))); // NOI18N
		btMoveRight.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btMoveRightActionPerformed(evt);
			}
		});

		btMoveLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/assets/l.png"))); // NOI18N
		btMoveLeft.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btMoveLeftActionPerformed(evt);
			}
		});

		jLabel15.setText("Passo (%)");

		tfMoveStep.setText("20");

		javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(
				jPanel7);
		jPanel7.setLayout(jPanel7Layout);
		jPanel7Layout
				.setHorizontalGroup(jPanel7Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel7Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel7Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																btMoveDown)
														.addGroup(
																jPanel7Layout
																		.createSequentialGroup()
																		.addComponent(
																				btMoveLeft)
																		.addGap(18,
																				18,
																				18)
																		.addComponent(
																				btMoveUp)))
										.addGap(18, 18, 18)
										.addGroup(
												jPanel7Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																btMoveRight)
														.addGroup(
																jPanel7Layout
																		.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.TRAILING,
																				false)
																		.addComponent(
																				tfMoveStep,
																				javax.swing.GroupLayout.Alignment.LEADING)
																		.addComponent(
																				jLabel15,
																				javax.swing.GroupLayout.Alignment.LEADING,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)))
										.addGap(17, 17, 17)));
		jPanel7Layout
				.setVerticalGroup(jPanel7Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel7Layout
										.createSequentialGroup()
										.addComponent(btMoveUp)
										.addGap(8, 8, 8)
										.addGroup(
												jPanel7Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																btMoveLeft)
														.addComponent(
																btMoveRight))
										.addGroup(
												jPanel7Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																jPanel7Layout
																		.createSequentialGroup()
																		.addGap(8,
																				8,
																				8)
																		.addComponent(
																				btMoveDown))
														.addGroup(
																jPanel7Layout
																		.createSequentialGroup()
																		.addGap(18,
																				18,
																				18)
																		.addComponent(
																				jLabel15)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				tfMoveStep,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addContainerGap()));

		jPanel10.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Rotacionar"));

		btRotateLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/assets/rl.png"))); // NOI18N
		btRotateLeft.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btRotateLeftActionPerformed(evt);
			}
		});

		btRotateRight.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/assets/rr.png"))); // NOI18N
		btRotateRight.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btRotateRightActionPerformed(evt);
			}
		});

		jLabel18.setText("Graus");

		tfRotateDeg.setText("30");

		javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(
				jPanel10);
		jPanel10.setLayout(jPanel10Layout);
		jPanel10Layout
				.setHorizontalGroup(jPanel10Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel10Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(btRotateLeft)
										.addGap(34, 34, 34)
										.addGroup(
												jPanel10Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																false)
														.addComponent(
																tfRotateDeg,
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																jLabel18,
																javax.swing.GroupLayout.Alignment.LEADING))
										.addGap(39, 39, 39)
										.addComponent(btRotateRight)
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));
		jPanel10Layout
				.setVerticalGroup(jPanel10Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel10Layout
										.createSequentialGroup()
										.addGroup(
												jPanel10Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																jPanel10Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel18)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				tfRotateDeg,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addComponent(
																btRotateRight)
														.addComponent(
																btRotateLeft))
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));

		jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder("Zoom"));

		btZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/assets/zo.png"))); // NOI18N
		btZoomOut.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btZoomOutActionPerformed(evt);
			}
		});

		btZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/assets/zi.png"))); // NOI18N
		btZoomIn.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btZoomInActionPerformed(evt);
			}
		});

		jLabel19.setText("Passo");

		tfZoomStep.setText("20");

		javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(
				jPanel11);
		jPanel11.setLayout(jPanel11Layout);
		jPanel11Layout
				.setHorizontalGroup(jPanel11Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel11Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(btZoomOut)
										.addGap(34, 34, 34)
										.addGroup(
												jPanel11Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																false)
														.addComponent(
																tfZoomStep,
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																jLabel19,
																javax.swing.GroupLayout.Alignment.LEADING))
										.addGap(39, 39, 39)
										.addComponent(btZoomIn)
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));
		jPanel11Layout
				.setVerticalGroup(jPanel11Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel11Layout
										.createSequentialGroup()
										.addGroup(
												jPanel11Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																jPanel11Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel19)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				tfZoomStep,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addComponent(btZoomIn)
														.addComponent(btZoomOut))
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));

		javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
				jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout
				.setHorizontalGroup(jPanel1Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel1Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																jPanel10,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																jPanel7,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																287,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap(14, Short.MAX_VALUE))
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap(14, Short.MAX_VALUE)
										.addComponent(
												jPanel11,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap()));
		jPanel1Layout
				.setVerticalGroup(jPanel1Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												jPanel7,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												259,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addComponent(
												jPanel10,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jPanel11,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(24, 24, 24)));

		jTabbedPane1.addTab("Window ", jPanel1);

		label1.setText("Lista de objetos:");

		btEditShape.setText("Editar");
		btEditShape.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btEditShapeActionPerformed(evt);
			}
		});

		btRemoveShape.setText("Remover");
		btRemoveShape.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btRemoveShapeActionPerformed(evt);
			}
		});

		jLabel1.setText("Novo objeto:");

		jLabel2.setText("Nome:");

		txShapeName.setText("Objeto");

		jLabel3.setText("Cor:");

		btColorShape.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				btColorShapeActionPerformed(evt);
			}
		});

		btRandomColor.setText("Random");
		btRandomColor.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btRandomColorActionPerformed(evt);
			}
		});

		jLabel4.setText("x");

		jLabel5.setText("y");

		jLabel6.setText("Coordenadas");

		btPtCreate.setText("Criar");
		btPtCreate.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btPtCreateActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(
				jPanel4);
		jPanel4.setLayout(jPanel4Layout);
		jPanel4Layout
				.setHorizontalGroup(jPanel4Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel4Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel4Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																jPanel4Layout
																		.createSequentialGroup()
																		.addGap(19,
																				19,
																				19)
																		.addGroup(
																				jPanel4Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addGroup(
																								jPanel4Layout
																										.createSequentialGroup()
																										.addComponent(
																												jLabel5)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addComponent(
																												tfPtY,
																												javax.swing.GroupLayout.PREFERRED_SIZE,
																												44,
																												javax.swing.GroupLayout.PREFERRED_SIZE))
																						.addGroup(
																								jPanel4Layout
																										.createSequentialGroup()
																										.addComponent(
																												jLabel4)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addComponent(
																												tfPtX,
																												javax.swing.GroupLayout.PREFERRED_SIZE,
																												44,
																												javax.swing.GroupLayout.PREFERRED_SIZE))))
														.addComponent(jLabel6))
										.addContainerGap(184, Short.MAX_VALUE))
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel4Layout
										.createSequentialGroup()
										.addContainerGap(217, Short.MAX_VALUE)
										.addComponent(
												btPtCreate,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												52,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap()));
		jPanel4Layout
				.setVerticalGroup(jPanel4Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel4Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(jLabel6)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel4Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel4)
														.addComponent(
																tfPtX,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel4Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel5)
														.addComponent(
																tfPtY,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												35, Short.MAX_VALUE)
										.addComponent(btPtCreate)
										.addContainerGap()));

		jTabbedPane2.addTab("Ponto", jPanel4);

		btLnCreate.setText("Criar");
		btLnCreate.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btLnCreateActionPerformed(evt);
			}
		});

		jLabel7.setText("y0");

		jLabel8.setText("x0");

		jLabel9.setText("Coordenadas");

		jLabel10.setText("x1");

		jLabel11.setText("y1");

		javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(
				jPanel5);
		jPanel5.setLayout(jPanel5Layout);
		jPanel5Layout
				.setHorizontalGroup(jPanel5Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel5Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel5Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(jLabel9)
														.addGroup(
																jPanel5Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel7)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				tfLnY0,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				44,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addGroup(
																jPanel5Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel8)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				tfLnX0,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				44,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addGap(12, 12, 12)
										.addGroup(
												jPanel5Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addGroup(
																jPanel5Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel11)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				tfLnY1,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				44,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addGroup(
																jPanel5Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel10)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				tfLnX1,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				44,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addContainerGap())
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel5Layout
										.createSequentialGroup()
										.addContainerGap(216, Short.MAX_VALUE)
										.addComponent(
												btLnCreate,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												53,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap()));
		jPanel5Layout
				.setVerticalGroup(jPanel5Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel5Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(jLabel9)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel5Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addGroup(
																jPanel5Layout
																		.createSequentialGroup()
																		.addGroup(
																				jPanel5Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel10)
																						.addComponent(
																								tfLnX1,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				jPanel5Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel11)
																						.addComponent(
																								tfLnY1,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE)))
														.addGroup(
																jPanel5Layout
																		.createSequentialGroup()
																		.addGroup(
																				jPanel5Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel8)
																						.addComponent(
																								tfLnX0,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				jPanel5Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel7)
																						.addComponent(
																								tfLnY0,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE))))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												35, Short.MAX_VALUE)
										.addComponent(btLnCreate)
										.addContainerGap()));

		jTabbedPane2.addTab("Reta", jPanel5);

		btPlCreate.setText("Criar");
		btPlCreate.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btPlCreateActionPerformed(evt);
			}
		});

		jLabel12.setText("y");

		jLabel13.setText("x");

		jLabel14.setText("Coordenadas");

		btPlAddPt.setText("Add ->");
		btPlAddPt.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btPlAddPtActionPerformed(evt);
			}
		});

		btPlRemovePoint.setText("Remove");
		btPlRemovePoint.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btPlRemovePointActionPerformed(evt);
			}
		});

		cbPlSolid.setText("Sólido");

		javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(
				jPanel6);
		jPanel6.setLayout(jPanel6Layout);
		jPanel6Layout
				.setHorizontalGroup(jPanel6Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel6Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel6Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																jPanel6Layout
																		.createSequentialGroup()
																		.addGroup(
																				jPanel6Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								jPanel6Layout
																										.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.TRAILING)
																										.addComponent(
																												btPlAddPt)
																										.addGroup(
																												jPanel6Layout
																														.createSequentialGroup()
																														.addComponent(
																																jLabel12)
																														.addPreferredGap(
																																javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																														.addComponent(
																																tfPlY,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																44,
																																javax.swing.GroupLayout.PREFERRED_SIZE))
																										.addGroup(
																												jPanel6Layout
																														.createSequentialGroup()
																														.addComponent(
																																jLabel13)
																														.addPreferredGap(
																																javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																														.addComponent(
																																tfPlX,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																44,
																																javax.swing.GroupLayout.PREFERRED_SIZE)))
																						.addComponent(
																								jLabel14))
																		.addGap(28,
																				28,
																				28)
																		.addComponent(
																				scrollPolPts,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				144,
																				Short.MAX_VALUE))
														.addGroup(
																jPanel6Layout
																		.createSequentialGroup()
																		.addComponent(
																				cbPlSolid)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																		.addGroup(
																				jPanel6Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING,
																								false)
																						.addGroup(
																								jPanel6Layout
																										.createSequentialGroup()
																										.addGap(12,
																												12,
																												12)
																										.addComponent(
																												btPlCreate,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE))
																						.addComponent(
																								btPlRemovePoint,
																								javax.swing.GroupLayout.Alignment.TRAILING))))
										.addContainerGap()));
		jPanel6Layout
				.setVerticalGroup(jPanel6Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel6Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel6Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																false)
														.addGroup(
																jPanel6Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel14)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				jPanel6Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel13)
																						.addComponent(
																								tfPlX,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				jPanel6Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel12)
																						.addComponent(
																								tfPlY,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE)))
														.addComponent(
																scrollPolPts,
																0, 0,
																Short.MAX_VALUE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addGroup(
												jPanel6Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(btPlAddPt)
														.addComponent(
																btPlRemovePoint))
										.addGap(8, 8, 8)
										.addGroup(
												jPanel6Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																btPlCreate)
														.addComponent(cbPlSolid))));

		scrollPolPts.setViewportView(lsPlPoints);

		jTabbedPane2.addTab("Poligono", jPanel6);

		javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(
				jPanel2);
		jPanel2.setLayout(jPanel2Layout);
		jPanel2Layout
				.setHorizontalGroup(jPanel2Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																jSeparator1,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																301,
																Short.MAX_VALUE)
														.addGroup(
																jPanel2Layout
																		.createSequentialGroup()
																		.addGroup(
																				jPanel2Layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								jLabel1)
																						.addGroup(
																								jPanel2Layout
																										.createSequentialGroup()
																										.addGroup(
																												jPanel2Layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.TRAILING)
																														.addComponent(
																																jLabel3)
																														.addComponent(
																																jLabel2))
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addGroup(
																												jPanel2Layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																														.addGroup(
																																jPanel2Layout
																																		.createSequentialGroup()
																																		.addComponent(
																																				btColorShape,
																																				javax.swing.GroupLayout.PREFERRED_SIZE,
																																				30,
																																				javax.swing.GroupLayout.PREFERRED_SIZE)
																																		.addPreferredGap(
																																				javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																																		.addComponent(
																																				btRandomColor))
																														.addComponent(
																																txShapeName,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																212,
																																javax.swing.GroupLayout.PREFERRED_SIZE))))
																		.addContainerGap(
																				34,
																				Short.MAX_VALUE))
														.addGroup(
																jPanel2Layout
																		.createSequentialGroup()
																		.addComponent(
																				btEditShape)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																				175,
																				Short.MAX_VALUE)
																		.addComponent(
																				btRemoveShape)
																		.addContainerGap())
														.addGroup(
																jPanel2Layout
																		.createSequentialGroup()
																		.addComponent(
																				jTabbedPane2,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				0,
																				Short.MAX_VALUE)
																		.addContainerGap())
														.addGroup(
																jPanel2Layout
																		.createSequentialGroup()
																		.addComponent(
																				scrollShapes,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				289,
																				Short.MAX_VALUE)
																		.addGap(12,
																				12,
																				12))
														.addGroup(
																jPanel2Layout
																		.createSequentialGroup()
																		.addComponent(
																				label1,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.PREFERRED_SIZE)
																		.addContainerGap(
																				193,
																				Short.MAX_VALUE)))));
		jPanel2Layout
				.setVerticalGroup(jPanel2Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												label1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addComponent(
												scrollShapes,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												122,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																btEditShape)
														.addComponent(
																btRemoveShape))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jSeparator1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												6,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(jLabel1)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel2)
														.addComponent(
																txShapeName,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																btColorShape)
														.addComponent(
																btRandomColor)
														.addComponent(jLabel3))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jTabbedPane2,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												202,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap()));

		scrollShapes.setViewportView(lsShapes);

		jTabbedPane1.addTab("Objetos", jPanel2);

		jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder(
				new java.awt.Color(29, 29, 29), null));

		javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(
				jPanel3);
		jPanel3.setLayout(jPanel3Layout);
		jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanel3Layout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(viewport,
								javax.swing.GroupLayout.PREFERRED_SIZE, 525,
								javax.swing.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
		jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanel3Layout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(viewport,
								javax.swing.GroupLayout.PREFERRED_SIZE, 525,
								javax.swing.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(12, Short.MAX_VALUE)));

		jMenu1.setText("File");
		jMenuBar1.add(jMenu1);

		menuSobre.setText("Sobre...");
		menuSobre.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				menuSobreActionPerformed(evt);
			}
		});
		jMenuBar1.add(menuSobre);

		setJMenuBar(jMenuBar1);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addComponent(jTabbedPane1,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										321,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addComponent(jPanel3,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addContainerGap()));
		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGap(12, 12, 12)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.TRAILING,
												false)
												.addComponent(
														jTabbedPane1,
														javax.swing.GroupLayout.Alignment.LEADING,
														0, 0, Short.MAX_VALUE)
												.addComponent(
														jPanel3,
														javax.swing.GroupLayout.Alignment.LEADING,
														javax.swing.GroupLayout.DEFAULT_SIZE,
														javax.swing.GroupLayout.DEFAULT_SIZE,
														Short.MAX_VALUE))
								.addContainerGap()));

		pack();
	}// </editor-fold>

	private void menuSobreActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	// ********************
	// MOVE EVENTS
	private void btMoveUpActionPerformed(java.awt.event.ActionEvent evt) {
		int passo = Integer.parseInt(tfMoveStep.getText());

		displayFile.window.move(0, passo);
		viewport.update(viewport.getGraphics());
	}

	private void btMoveLeftActionPerformed(java.awt.event.ActionEvent evt) {
		int passo = Integer.parseInt(tfMoveStep.getText());

		displayFile.window.move(-passo, 0);
		viewport.update(viewport.getGraphics());
	}

	private void btMoveRightActionPerformed(java.awt.event.ActionEvent evt) {
		int passo = Integer.parseInt(tfMoveStep.getText());

		displayFile.window.move(passo, 0);
		viewport.update(viewport.getGraphics());
	}

	private void btMoveDownActionPerformed(java.awt.event.ActionEvent evt) {
		int passo = Integer.parseInt(tfMoveStep.getText());

		displayFile.window.move(0, -passo);
		viewport.update(viewport.getGraphics());
	}

	// **********************
	// ROTATE EVENTS
	private void btRotateLeftActionPerformed(java.awt.event.ActionEvent evt) {
		displayFile.window.rotate(-Integer.parseInt(tfRotateDeg.getText()));
		viewport.update(viewport.getGraphics());
	}

	private void btRotateRightActionPerformed(java.awt.event.ActionEvent evt) {
		displayFile.window.rotate(Integer.parseInt(tfRotateDeg.getText()));
		viewport.update(viewport.getGraphics());
	}

	// ********************
	// ZOOM EVENTS
	private void btZoomOutActionPerformed(java.awt.event.ActionEvent evt) {
		int passo = Integer.parseInt(tfZoomStep.getText());

		displayFile.window.zoomOut(passo);
		viewport.update(viewport.getGraphics());
	}

	private void btZoomInActionPerformed(java.awt.event.ActionEvent evt) {
		int passo = Integer.parseInt(tfZoomStep.getText());

		displayFile.window.zoomIn(passo);
		viewport.update(viewport.getGraphics());
	}

	// *********************
	// OBJECTS LIST EVENTS
	private void btEditShapeActionPerformed(java.awt.event.ActionEvent evt) {
		if (lsShapes.getSelectedValue() != null) {
			Shape obj = displayFile.shapes.get(lsShapes.getSelectedValue());
			TransformFrame transF = new TransformFrame(obj,viewport);
			transF.setVisible(true);
		}
	}

	private void btRemoveShapeActionPerformed(java.awt.event.ActionEvent evt) {
		if (lsShapes.getSelectedValue() != null) {
			displayFile.removeShape(lsShapes.getSelectedValue().toString());
			shapeList.removeElement(lsShapes.getSelectedValue());
			viewport.update(viewport.getGraphics());
		}
	}

	// NEW OBJECT EVENTS
	private void btColorShapeActionPerformed(java.awt.event.MouseEvent evt) {
		Color newC = JColorChooser.showDialog(this, "Choose Background Color",
				color);
		if (newC != null) {
			color = newC;
			btColorShape.setBackground(color);
		}
	}

	private void btRandomColorActionPerformed(java.awt.event.ActionEvent evt) {
		Random numGen = new Random();
		color = new Color(numGen.nextInt(256), numGen.nextInt(256),
				numGen.nextInt(256));
		btColorShape.setBackground(color);
	}

	// CREATE POINT
	private void btPtCreateActionPerformed(java.awt.event.ActionEvent evt) {
		double x, y;
		try {
			x = Double.parseDouble(tfPtX.getText());
			y = Double.parseDouble(tfPtY.getText());
		} catch (Exception e) {
			JOptionPane.showMessageDialog(jPanel1,
					"Digite coordenadas válidas!");
			return;
		}

		name = txShapeName.getText();
		if (name.equals("")) {
			JOptionPane.showMessageDialog(jPanel1,
					"Digite um nome para a figura");
			return;
		}
		if (displayFile.shapes.get(name) != null) {
			JOptionPane.showMessageDialog(null,
					"Já existe uma figura com este nome!\n Escolha outro");
			return;
		}

		double[][] pts = { { x }, { y } };
		displayFile.addPonto(pts, color, name);
		viewport.update(viewport.getGraphics());
		shapeList.addElement(name);
		txShapeName.setText("");

	}

	// CREATE LINE
	private void btLnCreateActionPerformed(java.awt.event.ActionEvent evt) {
		double x0, y0, x1, y1;
		try {
			x0 = Double.parseDouble(tfLnX0.getText());
			y0 = Double.parseDouble(tfLnY0.getText());
			x1 = Double.parseDouble(tfLnX1.getText());
			y1 = Double.parseDouble(tfLnY1.getText());
		} catch (Exception e) {
			JOptionPane.showMessageDialog(jPanel1,
					"Digite coordenadas válidas!");
			return;
		}

		name = txShapeName.getText();
		if (name.equals("")) {
			JOptionPane.showMessageDialog(jPanel1,
					"Digite um nome para a figura");
			return;
		}
		if (displayFile.shapes.get(name) != null) {
			JOptionPane.showMessageDialog(null,
					"Já existe uma figura com este nome!\n Escolha outro");
			return;
		}

		double[][] pts = { { x0, x1 }, { y0, y1 } };
		displayFile.addLinha(pts, color, name);
		viewport.update(viewport.getGraphics());
		shapeList.addElement(name);
		txShapeName.setText("");
	}

	// CREATE POLIGON
	private void btPlCreateActionPerformed(java.awt.event.ActionEvent evt) {
		name = txShapeName.getText();
		if (name.equals("")) {
			JOptionPane.showMessageDialog(jPanel1,
					"Digite um nome para a figura");
			return;
		}
		if (displayFile.shapes.get(name) != null) {
			JOptionPane.showMessageDialog(null,
					"Já existe uma figura com este nome!\n Escolha outro");
			return;
		}

		double[][] pts = new double[2][polPtsList.getSize()];

		for (int i = 0; i < polPtsList.getSize(); i++) {
			String v = (String) polPtsList.get(i);
			String[] pt = v.split(";");
			pts[0][i] = Double.valueOf(pt[0]);
			pts[1][i] = Double.valueOf(pt[1]);
		}

		displayFile.addPoligono(pts, color, name, cbPlSolid.isSelected());
		viewport.update(viewport.getGraphics());
		shapeList.addElement(name);
		txShapeName.setText("");
		polPtsList.removeAllElements();
	}

	private void btPlAddPtActionPerformed(java.awt.event.ActionEvent evt) {
		double x, y;
		try {
			x = Double.parseDouble(tfPlX.getText());
			y = Double.parseDouble(tfPlY.getText());
		} catch (Exception e) {
			JOptionPane.showMessageDialog(jPanel1,
					"Digite coordenadas válidas!");
			return;
		}
		String ponto = x + ";" + y;
		polPtsList.addElement(ponto);
	}

	private void btPlRemovePointActionPerformed(java.awt.event.ActionEvent evt) {
		polPtsList.removeElement(lsPlPoints.getSelectedValue());
	}

	private javax.swing.JPanel btColorShape;
	private javax.swing.JButton btEditShape;
	private javax.swing.JButton btLnCreate;
	private javax.swing.JButton btMoveDown;
	private javax.swing.JButton btMoveLeft;
	private javax.swing.JButton btMoveRight;
	private javax.swing.JButton btMoveUp;
	private javax.swing.JButton btPlAddPt;
	private javax.swing.JButton btPlCreate;
	private javax.swing.JButton btPlRemovePoint;
	private javax.swing.JButton btPtCreate;
	private javax.swing.JButton btRandomColor;
	private javax.swing.JButton btRemoveShape;
	private javax.swing.JButton btRotateLeft;
	private javax.swing.JButton btRotateRight;
	private javax.swing.JButton btZoomIn;
	private javax.swing.JButton btZoomOut;
	private javax.swing.JCheckBox cbPlSolid;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel10;
	private javax.swing.JLabel jLabel11;
	private javax.swing.JLabel jLabel12;
	private javax.swing.JLabel jLabel13;
	private javax.swing.JLabel jLabel14;
	private javax.swing.JLabel jLabel15;
	private javax.swing.JLabel jLabel18;
	private javax.swing.JLabel jLabel19;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JLabel jLabel7;
	private javax.swing.JLabel jLabel8;
	private javax.swing.JLabel jLabel9;
	private javax.swing.JMenu jMenu1;
	private javax.swing.JMenuBar jMenuBar1;
	private javax.swing.JPanel jPanel1;
	private javax.swing.JPanel jPanel10;
	private javax.swing.JPanel jPanel11;
	private javax.swing.JPanel jPanel2;
	private javax.swing.JPanel jPanel3;
	private javax.swing.JPanel jPanel4;
	private javax.swing.JPanel jPanel5;
	private javax.swing.JPanel jPanel6;
	private javax.swing.JPanel jPanel7;
	private javax.swing.JSeparator jSeparator1;
	private javax.swing.JTabbedPane jTabbedPane1;
	private javax.swing.JTabbedPane jTabbedPane2;
	private java.awt.Label label1;
	private javax.swing.JList lsPlPoints;
	private javax.swing.JList lsShapes;
	private javax.swing.JMenu menuSobre;
	private javax.swing.JTextField tfLnX0;
	private javax.swing.JTextField tfLnX1;
	private javax.swing.JTextField tfLnY0;
	private javax.swing.JTextField tfLnY1;
	private javax.swing.JTextField tfMoveStep;
	private javax.swing.JTextField tfPlX;
	private javax.swing.JTextField tfPlY;
	private javax.swing.JTextField tfPtX;
	private javax.swing.JTextField tfPtY;
	private javax.swing.JTextField tfRotateDeg;
	private javax.swing.JTextField tfZoomStep;
	private javax.swing.JTextField txShapeName;
	private Viewport viewport;
	private javax.swing.JScrollPane scrollShapes;
	private javax.swing.JScrollPane scrollPolPts;

	// End of variables declaration
}
